#include<bits/stdc++.h>
#define ll long long
#define endl '\n'
using namespace std;
int d[100005];
int v[100005];
int a[100005];
int c[100005];
bool q[100005];
int ans1,ans2;
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t;
    cin>>t;
    int n,m,L,V;
    while(t--){
        bool f=1;
        ans1=0;
        ans2=0;
        cin>>n>>m>>L>>V;
        vector<int> ve;
        for(int i=0;i<n;i++){
            cin>>d[i]>>v[i]>>a[i];
        }
        for(int i=0;i<m;i++){
            cin>>c[i];
        }
        for(int i=0;i<n;i++){
            f=1;
            if(a[i]>0){
                if(d[i]<=c[m-1]){
                    //cout<<V*V<<endl<<2<<"*"<<a[i]<<"*"<<"("<<c[m-1]<<"-"<<d[i]<<")"<<endl;
                    if(V*V<v[i]*v[i]+2*a[i]*(c[m-1]-d[i])){
                        f=0;
                        ans1++;
                            //cout<<i+1<<endl;
                    }
                }
            }
            else if(a[i]<0){
                int j=0;
                if(d[i]<=c[m-1]){
                    while(d[i]>c[j]){
                        j++;
                    }
                    //cout<<V*V<<endl<<2<<"*"<<a[i]<<"*"<<"("<<c[m-1]<<"-"<<d[i]<<")"<<endl;
                    if(V*V<v[i]*v[i]+2*a[i]*(c[j]-d[i])){
                        f=0;
                        ans1++;
                        //cout<<i+1<<endl;
                    }
                }
            }
            else{
                if(d[i]<=c[m-1]){
                    if(V<v[i]){
                        f=0;
                        ans1++;
                        int j=0;
                        while(d[i]>c[j]){
                            j++;
                        }
                        //cout<<i+1<<endl;
                    }
                }
            }
            if(f){
                q[i]=1;
            }
        }
        cout<<ans1<<" ";
        bool f1,f2;
        for(int i=0;i<m;i++){
            f1=1;
            for(int j=0;j<n;j++){
                if(!q[j]){
                    f2=0;
                    for(int k=0;k<m;k++){
                        if(c[k]>=d[j]&&k!=i&&V*V<v[j]*v[j]+2*a[j]*(c[k]-d[j])){
                            f2=1;
                            //cout<<i<<" "<<j<<" "<<k<<endl;
                            break;
                        }

                    }

                }
                else{
                    f2=1;
                }
                if((!f2)){
                    f1=0;
                    break;
                }
            }
            if(f1){
                //cout<<i<<endl;
                ve.push_back(i);
            }
        }
        bool f8=0;
        ans2=1;
        if(ve.size()==1){
            cout<<1<<endl;
        }
        else{
            for(int i=0;i<ve.size();i++){
                ans2++;
            }
            ans2-=4;
            cout<<ans2<<endl;
        }

    }
    return 0;
}
